import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class SetDemo {

	public static void main(String[] args) {
		Set<String> set = new HashSet<String>();

		// We can add items
		set.add("Zagorka");
		set.add("Ariana");
		set.add("Shumensko");
		set.add("Kamenitza");
		// No duplicate elements
		System.out.println("operation sucess? "+ set.add("Ariana"));
		set.add("Shumensko");

		// We can check if item exists in our list
		System.out.println(set.contains("Kamenitza")); // true
		System.out.println(set.contains("Guinnes")); // false

		// We can retrieve the list size
		System.out.println(set.size());

		// We can remove an item
		set.remove("Ariana");

		// We can iterate over the set using Iterator
		Iterator<String> i = set.iterator();
		while (i.hasNext()) {
			System.out.println(i.next());
		}
		
		System.out.println();

		// We can retrieve all elements as array
		Object[] elements = set.toArray();
		for (Object el : elements) {
			System.out.println(el);
		}

		System.out.println();

		Set<String> orderedSet = new TreeSet<String>();
		orderedSet.add("Pesho");
		orderedSet.add("Kiro");
		orderedSet.add("Gosho");

		System.out.println(orderedSet);

		System.out.println();
		uniqueNumbers();

	}

	public static void uniqueNumbers() {
		Set<Integer> s = new HashSet<Integer>();
		Scanner scanner = new Scanner(System.in);
		System.out.println("Enter integer numbers: ");
		while (scanner.hasNextInt()) {
			s.add(scanner.nextInt());
		}
		System.out.println(s);
	}

}
